﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.partakeinfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int ptid=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(ptid);
				}
			}
		}
			
	private void ShowInfo(int ptid)
	{
		lcs.BLL.partakeinfo bll=new lcs.BLL.partakeinfo();
		lcs.Model.partakeinfo model=bll.GetModel(ptid);
		this.lblptid.Text=model.ptid.ToString();
		this.txtdpid.Text=model.dpid.ToString();
		this.txtsid.Text=model.sid.ToString();
		this.txtbidmoney.Text=model.bidmoney.ToString();
		this.txtbond.Text=model.bond.ToString();
		this.chkisbid.Checked=model.isbid;
		this.txtdocmoney.Text=model.docmoney.ToString();
		this.chkisendbid.Checked=model.isendbid;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtdpid.Text))
			{
				strErr+="计划编号格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtsid.Text))
			{
				strErr+="供应商编号格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtbidmoney.Text))
			{
				strErr+="中标价格格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtbond.Text))
			{
				strErr+="保证金格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtdocmoney.Text))
			{
				strErr+="标书费格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int ptid=int.Parse(this.lblptid.Text);
			int dpid=int.Parse(this.txtdpid.Text);
			int sid=int.Parse(this.txtsid.Text);
			decimal bidmoney=decimal.Parse(this.txtbidmoney.Text);
			decimal bond=decimal.Parse(this.txtbond.Text);
			bool isbid=this.chkisbid.Checked;
			decimal docmoney=decimal.Parse(this.txtdocmoney.Text);
			bool isendbid=this.chkisendbid.Checked;


			lcs.Model.partakeinfo model=new lcs.Model.partakeinfo();
			model.ptid=ptid;
			model.dpid=dpid;
			model.sid=sid;
			model.bidmoney=bidmoney;
			model.bond=bond;
			model.isbid=isbid;
			model.docmoney=docmoney;
			model.isendbid=isendbid;

			lcs.BLL.partakeinfo bll=new lcs.BLL.partakeinfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
